import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** CRM 客户门店信息 */
export interface Store {
          id: number; // 编号，主键自增
          customerId: number; // 所属客户id
          storeName: string; // 门店名称
          storeNo: string; // 门店编号
          contactId: number; // 联系人编号
          areaId: number; // 地区编号
          detailAddress: string; // 详细地址
          level: number; // 门店等级
          contactName: string,
          contactPhone: string,
          storeArea: number,
          remark: string; // 备注
  }

// CRM 客户门店 API
export const StoreApi = {
  // 查询CRM 客户门店分页
  getStorePage: async (params: any) => {
    return await request.get({ url: `/crm/store/page`, params })
  },

  // 查询CRM 客户门店详情
  getStore: async (id: number) => {
    return await request.get({ url: `/crm/store/get?id=` + id })
  },

  // 新增CRM 客户门店
  createStore: async (data: Store) => {
    return await request.post({ url: `/crm/store/create`, data })
  },

  // 修改CRM 客户门店
  updateStore: async (data: Store) => {
    return await request.put({ url: `/crm/store/update`, data })
  },

  // 删除CRM 客户门店
  deleteStore: async (id: number) => {
    return await request.delete({ url: `/crm/store/delete?id=` + id })
  },

  /** 批量删除CRM 客户门店 */
  deleteStoreList: async (ids: number[]) => {
    return await request.delete({ url: `/crm/store/delete-list?ids=${ids.join(',')}` })
  },

  // 导出CRM 客户门店 Excel
  exportStore: async (params) => {
    return await request.download({ url: `/crm/store/export-excel`, params })
  },
  // 门店列表
  getStoreSimpleList:async () =>{
    return await request.get({ url: `/crm/store/simple-list` })
  }
}
